package com.bocai.eelly.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.bocai.eelly.R;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * Created by admin on 2016/5/30.
 */
public class HomeAdp extends BaseAdapter {
    private Context context;
    private String[] texts;
    private int[] pics;
    public HomeAdp(Context context,String [] texts,int [] pics) {
        this.context = context;
        this.texts=texts;
        this.pics=pics;
    }

    @Override
    public int getCount() {
        return texts.length;
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder viewHolder;
        if (convertView == null) {
            convertView = LayoutInflater.from(context).inflate(R.layout.home_item, null);
            viewHolder = new ViewHolder(convertView);
            convertView.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder) convertView.getTag();
        }
        viewHolder.ivHomeItemPic.setImageResource(pics[position]);
        viewHolder.tvHomeItemText.setText(texts[position]);
        return convertView;
    }


    class ViewHolder {
        @Bind(R.id.iv_home_item_pic)
        ImageView ivHomeItemPic;
        @Bind(R.id.tv_home_item_text)
        TextView tvHomeItemText;

        ViewHolder(View view) {
            ButterKnife.bind(this, view);
        }
    }
}
